package com.gollum.jpa.enums;


import com.gollum.jpa.util.StrUtils;

/**
 * 查询规则枚举
 *
 * @author Herther
 * @version 1.0.0
 * @ClassName QueryRuleEnum.java
 * @createTime 2022年07月16日 23:00:00
 */
public enum QueryRuleEnum {

    GT(">","gt","大于"),

    GE(">=","ge","大于等于"),
    LT("<","lt","小于"),
    LE("<=","le","小于等于"),
    EQ("=","eq","等于"),
    NE("!=","ne","不等于"),

    IN("IN","in","包含"),
    LIKE("LIKE","like","全模糊"),
    LEFT_LIKE("LEFT_LIKE","left_like","左模糊"),
    RIGHT_LIKE("RIGHT_LIKE","right_like","右模糊"),

    BETWEEN("BETWEEN","between","在什么范围"),

    NOT_LIKE("NOT_LIKE","not_like","不模糊");

    private String value;

    private String condition;

    private String msg;

    QueryRuleEnum(String value, String condition, String msg) {
        this.value = value;
        this.condition = condition;
        this.msg = msg;
    }

    /**
     * 功能描述: 获取枚举的value值
     * @param:
     * @return:
     * @auther: Herther
     * @version 1.0.0
     * @date: 2022/7/16 23:02
     */
    public static QueryRuleEnum getByValue(String value){
        if(StrUtils.isBlank(value)) {
            return null;
        }
        for(QueryRuleEnum val :values()){
            if (val.getValue().equals(value) || val.getCondition().equals(value.toLowerCase())){
                return val;
            }
        }
        return  null;
    }


    public String getValue() {
        return value;
    }

    public String getCondition() {
        return condition;
    }

    public String getMsg() {
        return msg;
    }
}
